package pm.config;

import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.load.Persister;

import java.io.File;
import java.math.BigDecimal;

/**
 * @author Anton Bernatski
 */
@Root(name = "pm")
public class Configuration {

	@Element
	private int drivesUpdateTime;

	@Element
	private String nativeLibName;

	@Element
    private String adminKey;

    @Element
    private String ooHome;

    private BigDecimal printPrice;

    private BigDecimal scanPrice;

    public void save(String path) throws Exception {
		Serializer serializer = new Persister();
		File file = new File(path);
		serializer.write(this, file);
	}

	public static Configuration load(String path) throws Exception {
		Serializer serializer = new Persister();
		return serializer.read(Configuration.class, new File(path));
	}

    public int getDrivesUpdateTime() {
        return drivesUpdateTime;
    }

    public void setDrivesUpdateTime(int drivesUpdateTime) {
        this.drivesUpdateTime = drivesUpdateTime;
    }

	public String getNativeLibName() {
		return nativeLibName;
	}

	public void setNativeLibName(final String nativeLibName) {
		this.nativeLibName = nativeLibName;
	}

	public String getAdminKey() {
		return adminKey;
	}

	public void setAdminKey(final String adminKey) {
		this.adminKey = adminKey;
	}

    public String getOoHome() {
        return ooHome;
    }

    public void setOoHome(String ooHome) {
        this.ooHome = ooHome;
    }

    public BigDecimal getPrintPrice() {
        return printPrice;
    }

    public void setPrintPrice(BigDecimal printPrice) {
        this.printPrice = printPrice;
    }

    public BigDecimal getScanPrice() {
        return scanPrice;
    }

    public void setScanPrice(BigDecimal scanPrice) {
        this.scanPrice = scanPrice;
    }
}